package com.zscat.mallplus.sms.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zscat.mallplus.sms.entity.SmsCouponHistory;
import com.zscat.mallplus.sms.mapper.SmsCouponHistoryMapper;
import com.zscat.mallplus.sms.service.ISmsCouponHistoryService;
import com.zscat.mallplus.ums.entity.UmsMember;
import com.zscat.mallplus.ums.service.IUmsMemberService;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 优惠券使用、领取历史表 服务实现类
 * </p>
 *
 * @author zscat
 * @since 2019-04-19
 */
@Service
public class SmsCouponHistoryServiceImpl extends ServiceImpl<SmsCouponHistoryMapper, SmsCouponHistory> implements ISmsCouponHistoryService {

    @Resource
    private SmsCouponHistoryMapper couponHistoryMapper;

    @Resource
    private IUmsMemberService memberService;

    /**
     * 查询当前优惠券是否已领取
     *
     * @param couponId
     * @param memberId
     * @return
     */
    public int checkIsReceive(Long couponId, Long memberId) {
        return couponHistoryMapper.checkIsReceive(couponId, memberId);
    }

    /**
     * 查询用户购买商品领取的优惠券信息
     *
     * @param memberId
     * @param productId
     * @return
     */
    public SmsCouponHistory selectCouponInfo(Long memberId, Long productId) {
        return couponHistoryMapper.selectCouponInfo(memberId, productId);
    }
}
